package com.rjpacket.chileme.app.models;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.List;

/**
 * Created by Administrator on 2015/3/24 0024.
 */


public class MainHeadView {
    private List<MainHeadUp> up;

    public List<MainHeadDown> getDown() {
        return down;
    }

    public void setDown(List<MainHeadDown> down) {
        this.down = down;
    }

    public List<MainHeadUp> getUp() {
        return up;
    }

    public void setUp(List<MainHeadUp> up) {
        this.up = up;
    }

    private List<MainHeadDown> down;

    public void parseJSON(JSONObject jsonObject) {
        if (jsonObject != null) {
            try {
                JSONObject object = jsonObject.getJSONObject("home");
                JSONArray promotion = object.getJSONArray("promotions");
                JSONArray banner = object.getJSONArray("banners");
                for (int i = 0; i < promotion.length(); i++) {
                    JSONObject json = promotion.getJSONObject(i);
                    MainHeadUp mainHeadUp = new MainHeadUp();
                    mainHeadUp.parseJSON(json);
                    up.add(mainHeadUp);
                }

                for (int i = 0; i < banner.length(); i++) {
                    JSONObject json = promotion.getJSONObject(i);
                    MainHeadDown mainHeadDown = new MainHeadDown();
                    mainHeadDown.parseJSON(json);
                    down.add(mainHeadDown);
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }
}